<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<script src="../../js/jquery.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/public.js"></script>
	<link rel="stylesheet" type="text/css" href="../../css/public.css">
</head>

<body class="bg">
	<div class="wrap-pd animated fadeInDown">
		<div class="main-content">
			<div class="main-description">
				<h1>请输入你的新密码</h1>
				<div class="ipt-box">
					<span>输入你的新密码</span>
					<input type="password" name="" id="newpwd" value="" />
				</div>
				<button type="button" class="btn" id="update-submit">提交</button>
			</div>
		</div>
	</div>
</body>

</html>
<script src="../../js/dream-msg.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

	productheader('body', 3, 1, 1);

	let tem = `	<a href=" /views/teacher/teachers.html"><span data-i18n-text="AnnualAvg">寻找老师</span></a>`

	$(".title-bar").empty().append(tem);
	$(".title-bar").css("height", "40px");
	$(".title-bar").css("marginLeft", "16px");
	$(".title-bar").css("borderLeft", "1px solid rgb(221 214 214)");

	$(".left-bar").hide();
	$(".apps").css("fontSize", "35px");
	$("#left-go").css("position", "relative");
	$("#left-go").css("left", "25px");
	productfooter('body', 4);
	// 预加载隐藏
	$(document).ready(function () {
		$("#time").fadeOut("slow").hide();
	})


	//修改新密码
	$('#update-submit').click(async function () {

		let username = localStorage.getItem('curuser');
		let newpwd = $('#newpwd').val();


		// 获取手机号
		let res;
		if (username && newpwd.length > 5) {
			if (phonetest(username)) {
				res = await ajax('student_phone_update', { 'phone': username, 'password': newpwd }, 'POST');
			} else {
				res = await ajax('student_mailbox_password', { 'mailbox': username, 'password': newpwd }, 'POST');
			}
			if (res.code == 200) {
				Dreamer.success('修改密码成功请重新登录', 2000);
				let params = {
					'mailbox': username,
					'password': newpwd,
				};
				localStorage.setItem('params', JSON.stringify(params));

				localStorage.removeItem('curuser');

				window.location.href = '../../index.html';

			} else {
				Dreamer.error('提交失败,密码长度必须大于6位数', 2000);
			}
		} else {
			Dreamer.error('提交失败,密码长度必须大于6位数', 2000);
		}

	})

</script>
<style type="text/css">
	.bg {
		background-color: rgba(237, 239, 240, 1);
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
	}

	.wrap-pd {
		width: 100%;
		height: auto;
		padding: 5% 0 15% 0;
	}

	.main-content {
		width: 20%;
		padding: 20px 30px;
		box-shadow: #EDEFF0 0px 0px 3px 1px;
		border: 1px solid #EDEFF0;
		background-color: #fff;
		border-radius: 6px;
		margin: auto;
		margin-top: 34px;
	}

	.main-description {
		display: flex;
		flex-flow: column nowrap;
		justify-content: center;
		align-items: center;
	}

	.main-description>h1 {
		width: 100%;
		margin-bottom: 25px;
	}

	.ipt-box {
		width: 100%;
		display: flex;
		align-items: center;
		margin-top: 3px;
	}

	.ipt-box>span {
		width: auto;
		white-space: nowrap;
		display: inline-block;
		color: #888888;
		font-size: 14px;
	}

	.ipt-box>input {
		padding: 8px;
		box-sizing: border-box;
		display: flex;
		margin-left: 15px;
		flex: 1;
		border: 1px solid #CCCCCC;
		height: 30px;
	}

	.ipt-box>.yzm {
		margin-left: 15px;
		display: flex;
		flex: 1;
		border: 1px solid #CCCCCC;
		height: 30px;
		display: flex;
		flex-flow: row nowrap;
		align-items: center;
		padding: 8px;
		box-sizing: border-box;
		cursor: pointer;
	}

	.yzm>input {
		flex: 1;
		border: none;
		outline: none;
	}

	.yzm #verificationcode {
		display: block;
		background-color: #FAC443;
		padding: 2px 10px;
		border-radius: 4px;
		color: #fff;
	}

	.yzm #time {
		display: block;
		background-color: #CCCCCC;
		padding: 2px 10px;
		border-radius: 4px;
		color: #fff;
	}

	.btn {
		margin-top: 25px;
		width: 60%;
		color: #fff;
		border-radius: 6px;
		background-color: #5686E9;
		padding: 10px;
		border: none;
		outline: none;
		cursor: pointer;
	}

	input {
		border-radius: 2px;
	}
</style>